/**
 * 接口地址
 */
var basePath = "/pandora/",
	baseImgPath = "http://test.image.mama.devstudio.cn/",
	bigphoto = "@780w_780h_100Q.jpg",
	samllphoto = "@144w_144h_100Q.jpg",
	recordphoto = "@100w_180h_100Q.jpg",
	mediumphoto = "@400w_400h_100Q.jpg",
	i_addRequirement = basePath + "requirement/addRequirement"; //提交产品信息

/**
 * 通用拦截
 * @param  data 返回结果 
 * @return
 */
function checkCode(data) {
	var sta = false;
	switch (parseInt(data.code)) {
		case 0:
			break;
		default:
			alert(data.info);
			sta = true;
			break;
	}
	return sta;
}


/*//时间戳转换成日期
function getLocalTime(unixTime) {
	if (unixTime.length === 13) {
		unixTime = Math.round(unixTime / 1000);
	}
	var time = new Date(unixTime);
	var ymdhis = "";
	ymdhis += time.getFullYear() + "-";
	ymdhis += (time.getMonth() + 1) + "-";
	ymdhis += time.getDate();
	ymdhis += " " + time.getHours() + ":";
	ymdhis += time.getMinutes() + ":";
	ymdhis += time.getSeconds();
	return ymdhis;
}*/

//日期转换为时间戳
function getDateTime(string) {
	var f = string.split(' ', 2);
	var d = (f[0] ? f[0] : '').split('-', 3);
	var t = (f[1] ? f[1] : '').split(':', 3);
	return (new Date(
		parseInt(d[0], 10) || null, (parseInt(d[1], 10) || 1) - 1,
		parseInt(d[2], 10) || null,
		parseInt(t[0], 10) || null,
		parseInt(t[1], 10) || null,
		parseInt(t[2], 10) || null
	)).getTime();
}
//发图时间与系统时间差
function timeout(unixTime) {
	var date1 = new Date(unixTime); //发图时间
	var date2 = new Date(); //系统时间
	var date3 = date2.getTime() - date1.getTime(); //时间差的毫秒数
	var days = 0,
		leave1 = 0,
		leave2 = 0,
		hours = 0,
		minutes = 0;

	//计算出相差天数
	days = Math.floor(date3 / (24 * 3600 * 1000));
	if (days === 0) {
		//计算出小时数
		leave1 = date3 % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
		hours = Math.floor(leave1 / (3600 * 1000));
		if (hours === 0) {
			//计算相差分钟数
			leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
			minutes = Math.floor(leave2 / (60 * 1000));
		}
	}
	if (days !== 0) {
		return days + "天前";
	}
	if (hours !== 0) {
		return hours + "小时前";
	}
	if (minutes !== 0) {
		return minutes + "分前";
	}
}


function randomlabel() {
	var label = ["label-primary", "label-success", "label-info", "label-warning", "label-danger"],
		i = parseInt(Math.random() * 5);
	return label[i];
}